<template>
  <div class="login">
       <div class="form-group myWidth">
      <label for="exampleInputEmail1">用户名</label>
      <input
        type="username"
        class="form-control"
        id="exampleInputEmail1"
        placeholder="用户名"
        v-model="username"
      />
      {{ username }}
    </div>
    <div class="form-group myWidth">
      <label for="exampleInputPassword1">密码</label>
      <input
        type="password"
        class="form-control"
        id="exampleInputPassword1"
        placeholder="密码"
        v-model="password"
      />
      {{ password }}
    </div>

    <button type="submit" class="btn btn-default" @click="login">登录</button>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      username: "",
      password: "",
    };
  },

  methods: {
    login: function () {
      
      this.axios({
        method: 'post',
        url: 'http://127.0.0.1/taobao/user/login',
        data: {
          username: this.username,
          password: this.password,
        }
      }).then(function (response) {
        console.log(response.data);
      });
    },
  },
  created() {
    this.axios({
      method: 'post',
      url: 'http://127.0.0.1/taobao/user/login',
      data: {
        username: 'zs01',
        password: '123456',
      },
    }).then(function (response) {
      console.log(response.data);
    });
  },
};
</script>

<style>
.myWidth {
  width: 200px;
}
</style>
